package com.baizhi;

import com.baizhi.service.ProductService;
import com.baizhi.service.UserService;
import com.baizhi.service.impl.ProductServiceImpl;
import com.baizhi.service.impl.UserServiceImpl;
import org.apache.struts2.ServletActionContext;

import java.util.List;

public class UserAction {
    private String name;
    private String pwd;
    private UserService us=new UserServiceImpl();
    private ProductService ps=new ProductServiceImpl();
    private List<product> products;
    public String login(){
        ServletActionContext.getRequest().getSession().setAttribute("name",name);
        boolean login = us.login(name, pwd);
        if (login){
            return "sucess";
        }else return "defat";
    }
    public String findAll(){
        products = ps.selectAll();
        ServletActionContext.getRequest().getSession().setAttribute("products",products);
        return "show";
    }

    public List<product> getProducts() {
        return products;
    }

    public void setProducts(List<product> products) {
        this.products = products;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
}
